package cn.hxzy.office.service.impl;

import cn.hxzy.office.dao.EducationDao;
import cn.hxzy.office.entity.Education;
import cn.hxzy.office.service.EducationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Education)表服务实现类
 *
 * @author makejava
 * @since 2020-07-29 22:18:22
 */
@Service("educationService")
public class EducationServiceImpl implements EducationService {
    @Resource
    private EducationDao educationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Education queryById(Integer id) {
        return this.educationDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Education> queryAllByLimit(int offset, int limit) {
        return this.educationDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param education 实例对象
     * @return 实例对象
     */
    @Override
    public Education insert(Education education) {
        this.educationDao.insert(education);
        return education;
    }

    /**
     * 修改数据
     *
     * @param education 实例对象
     * @return 实例对象
     */
    @Override
    public Education update(Education education) {
        this.educationDao.update(education);
        return this.queryById(education.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.educationDao.deleteById(id) > 0;
    }

    @Override
    public List<Education> queryAll() {
        return educationDao.getAll();
    }
}